﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<z.m.db.Order>" %>

<table data-controller="Order_Detail" data-id="<%:Model.ID %>">
	<thead>
		<%
			Response.Write(Html.Partial("~/Views/Order_Detail/_Row.aspx", viewData: new ViewDataDictionary() { { "type", "header" } }));
			if (ViewData.ContainsKey("Add"))
				Response.Write(Html.Action("_Add", "Order_Detail", new { ParentID = Model.ID }));
		%>
	</thead>
	<tbody>
		<%
			var Sum = 0;
			foreach (var x in Model.Order_Details.OrderByDescending(x => x.ID)) {
				Response.Write(Html.Partial("~/Views/Order_Detail/_Row.aspx", x));
				Sum += x.Quantity * x.Unit_Price;
			}
		%>
	</tbody>
	<tfoot>
		<tr>
			<td colspan="6">Sum</td>
			<td><%:Html.TextBox("Total",Sum,"{0:$#,##0}", new {@readonly=true,@class="number"}) %></td>
			<% if (ViewData.ContainsKey("pay")) { %>
			<td colspan="99">
				<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
					<input type="hidden" name="cmd" value="_xclick">
					<input type="hidden" name="business" value="kaibazax@gmail.com">
					<input type="hidden" name="item_name"
						value="Memorex 256MB Memory Stick">
					<input type="hidden" name="item_number" value="MEM32507725">
					<input type="hidden" name="amount" value="3">
					<input type="hidden" name="currency_code" value="USD">
					<input type="hidden" name="return" value="order/pay" />
					<input type="hidden" name="rm" value="2" />
					<input type="submit" value="Pay" />
					<%--<input type="image" name="submit" border="0"
				src="https://www.paypalobjects.com/en_US/i/btn/btn_buynow_LG.gif"
				alt="PayPal - The safer, easier way to pay online">--%>
				</form>
			</td>
			<% } else { %>
			<td colspan="99"></td>
			<%} %>
		</tr>
		<% if (ViewData["type"] == "check") { %>
		<tr>
			<td colspan="99"><a href="<%:Url.Action("Create")%>?strOD=<%:ViewBag.strOD%>">Buy</a></td>
		</tr>
		<% }%>
	</tfoot>
</table>
<%:Scripts.Render("~/js/ckeditor") %>
<script>
	var editor;
	function installEditor(str) {
		if (editor) {
			editor.destroy();
		}
		editor = CKEDITOR.replace(el(str + " textarea"));
		//editor.setData(el(str + " textarea").innerHTML.trim(), function () { }, true);
	}
	function destroyEditor() {
		editor.destroy();
	}
</script>
